// CategoryGroup.cs
// 
// Copyright © 2009 FreeZzaph
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace LibFreeZzaph
{
	/// <summary>
	/// Represents a group of categories. A category group typically contains
	/// categories that provide the same types of files.
	/// The two most common category groups in the porn world are "pictures" and
	/// "movies", which thus likely will be the two most common category
	/// group types in all FreeZzaph content provider plug-ins.
	/// </summary>
	public class CategoryGroup
	{
		private string type;
		private string description;
		private IDictionary<string, Category> categories;
		
		/// <summary>
		/// Initializes a new instance of the CategoryGroup class with type and description.
		/// </summary>
		/// <param name="type">
		/// The type of category group this is. This value should be short,
		/// must be all lowercase, contain no whitespace and no special
		/// characters. Typical examples are "pictures" and "movies". Hyphens
		/// are allowed. A type that does not conform to these specifications
		/// will cause an ArgumentException to be thrown.
		/// </param>
		/// <param name="description">
		/// The description of this category group. This value should be a more
		/// descriptive name for the category group. Typically, this will be the
		/// same as the type, perhaps with some additional information attached,
		/// such as "Picture galleries" and "Movie galleries".
		/// </param>
		public CategoryGroup(string type, string description, IDictionary<string, Category> categories)
		{
			// Make sure the provided type is valid. If it's not, throw an
			// exception.
			string validType = Regex.Replace(type, "[^-a-z0-9]", "");
			if (type != validType)
				throw new ArgumentException("'type' argument contains illegal characters.");
			
			this.type = type;
			this.description = description;
			this.categories = categories;
		}
		
		/// <value>
		/// Gets the type of category group
		/// </value>
		public string Type
		{
			get
			{
				return type;
			}
		}
		
		/// <value>
		/// Gets the description of the category group
		/// </value>
		public string Description
		{
			get
			{
				return description;
			}
		}
		
		/// <value>
		/// Gets the dictionary containing the
		/// categories that this category group represents.
		/// </value>
		public IDictionary<string, Category> Categories
		{
			get
			{
				return new ReadOnlyDictionary<string, Category>(categories);
			}
		}
	}
}
